#ifndef _CONTRA_H
#define _CONTRA_H

#include "Character.h"
#include "Sprite.h"
#include "Collision.h"
#include "GunContra.h"
#include <vector>
#include <conio.h>
#include <iostream>
#include "MapGround.h"
#include "SuperTurret.h"
using namespace std;

class CContra :
	public CCharacter
{
private:
	CSprite *_rSprite;
	CSprite *_lSprite;
	CSprite *_fSprite;
	CSprite *_bossLight;

	bool _isRight;
	bool _isJump;
	bool _isMove;
	int _isDown;
	DWORD frame_start;
	DWORD tick_per_frame;
	int vpx, vpy;

	// bullet
	CSprite *_sprite_bullet;
	CSprite *_sprite_bullet_fire[8];
	CGunContra _gunContra;
	bool _gun;
	CTimer _gun_bullet, _gun_render;
	int _levelBullet;
	Sound _sound;
	CSound *_CSound;

	CMapGround *_botGround;
	void TopLandColl();
	void BotLandColl(int groundY);
	void TopWaterColl();
	void BotWaterColl(int groundY);
	void LeftColl(int groundY, int right);
	void RightColl(int groundY, int left);
	void NoColl(int groundY);

	//ground y
	int _groundY;

	//trang thai boi
	bool _isSwim;
	//trang thai roi
	bool _isFall;
	//
	bool _layAndFall;

	//
	DWORD _dwStartFall;

	//
	DWORD _dwFallTime;

public:
	CContra();
	~CContra(void);
	int ContraLoadSound(Sound isound);
	void LoadResource(LPDIRECT3DDEVICE9 d3ddv, LPD3DXSPRITE &SpriteHandler, HINSTANCE hInstance, HWND hWnd);	
	void ProcessInput();
	void ContraGun();
	void OnKeyUp(int KeyCode);
	void OnKeyDown(int KeyCode);
	void Contra_Die();
	void Contra_Run();
	void Update();
	void Render();
	void Contra_End();
	void ReadFileInputData(void);

	//xu ly va cham tren map
	void HandleCollisionOnMap(std::vector<CMapGround*> listObject);
	void TestSuperTurret(std::vector<CSuperTurret*> listObject);

	//lay box de xet va cham
	Box GetBox();

	void StartFall();
	void ProcessFall();
	void EndFall();

};
#endif
